/*
========================================================================
 Name        : SPDContainer.cpp
 Author      : 
 Copyright   : Your copyright notice
 Description : 
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <barsread.h>
#include <eikimage.h>
#include <eikenv.h>
#include <stringloader.h>
#include <eiklabel.h>
#include <aknviewappui.h>
#include <eikappui.h>
#include <akniconutils.h>
#include <Topbar.mbg>
#include <weather.mbg>
#include <smallicons.mbg>
#include <lineseparator.mbg>
#include <icons.mbg>
#include <SPD.rsg>
// ]]] end generated region [Generated System Includes]

// [[[ begin generated region: do not modify [Generated User Includes]
#include "SPDContainer.h"
#include "SPDContainerView.h"
#include "SPD.hrh"
// ]]] end generated region [Generated User Includes]

// [[[ begin generated region: do not modify [Generated Constants]
_LIT( KTopbarFile, "\\resource\\apps\\Topbar.mbm" );
_LIT( KweatherFile, "\\resource\\apps\\weather.mbm" );
_LIT( KsmalliconsFile, "\\resource\\apps\\smallicons.mbm" );
_LIT( KlineseparatorFile, "\\resource\\apps\\lineseparator.mbm" );
_LIT( KiconsFile, "\\resource\\apps\\icons.mbm" );
// ]]] end generated region [Generated Constants]

/**
 * First phase of Symbian two-phase construction. Should not 
 * contain any code that could leave.
 */
CSPDContainer::CSPDContainer()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	iLogo = NULL;
	iWeatherButton = NULL;
	iWeather = NULL;
	iCity = NULL;
	iTemperature = NULL;
	iDate = NULL;
	iWeatherDesc = NULL;
	iNoticeButton = NULL;
	iNoticeIcon = NULL;
	iNoticeText = NULL;
	iHomeseparator1 = NULL;
	iLifeServiceButton = NULL;
	iLifeServiceImage = NULL;
	iLifeServiceText = NULL;
	iDiscountInfoButton = NULL;
	iDiscountInfoImage = NULL;
	iDiscountInfoText = NULL;
	iProviderSearchButton = NULL;
	iProviderSearchImage = NULL;
	iProviderSearchText = NULL;
	iSiteSearchButton = NULL;
	iSiteSearchImage = NULL;
	iSiteSearchText = NULL;
	iProductInfoButton = NULL;
	iProductInfoImage = NULL;
	iProductInfoText = NULL;
	iFunGameButton = NULL;
	iFunGameImage = NULL;
	iFunGameText = NULL;
	iContactUsButton = NULL;
	iContactUsImage = NULL;
	iContactUsText = NULL;
	iSystemSettingButton = NULL;
	iSystemSettingImage = NULL;
	iSystemSettingText = NULL;
	iLineSeparator2 = NULL;
	iBottomImage = NULL;
	// ]]] end generated region [Generated Contents]
	
	}
/** 
 * Destroy child controls.
 */
CSPDContainer::~CSPDContainer()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	delete iLogo;
	iLogo = NULL;
	delete iWeatherButton;
	iWeatherButton = NULL;
	delete iWeather;
	iWeather = NULL;
	delete iCity;
	iCity = NULL;
	delete iTemperature;
	iTemperature = NULL;
	delete iDate;
	iDate = NULL;
	delete iWeatherDesc;
	iWeatherDesc = NULL;
	delete iNoticeButton;
	iNoticeButton = NULL;
	delete iNoticeIcon;
	iNoticeIcon = NULL;
	delete iNoticeText;
	iNoticeText = NULL;
	delete iHomeseparator1;
	iHomeseparator1 = NULL;
	delete iLifeServiceButton;
	iLifeServiceButton = NULL;
	iControlEventDispatch.Close();		
	delete iLifeServiceImage;
	iLifeServiceImage = NULL;
	delete iLifeServiceText;
	iLifeServiceText = NULL;
	delete iDiscountInfoButton;
	iDiscountInfoButton = NULL;
	delete iDiscountInfoImage;
	iDiscountInfoImage = NULL;
	delete iDiscountInfoText;
	iDiscountInfoText = NULL;
	delete iProviderSearchButton;
	iProviderSearchButton = NULL;
	delete iProviderSearchImage;
	iProviderSearchImage = NULL;
	delete iProviderSearchText;
	iProviderSearchText = NULL;
	delete iSiteSearchButton;
	iSiteSearchButton = NULL;
	delete iSiteSearchImage;
	iSiteSearchImage = NULL;
	delete iSiteSearchText;
	iSiteSearchText = NULL;
	delete iProductInfoButton;
	iProductInfoButton = NULL;
	delete iProductInfoImage;
	iProductInfoImage = NULL;
	delete iProductInfoText;
	iProductInfoText = NULL;
	delete iFunGameButton;
	iFunGameButton = NULL;
	delete iFunGameImage;
	iFunGameImage = NULL;
	delete iFunGameText;
	iFunGameText = NULL;
	delete iContactUsButton;
	iContactUsButton = NULL;
	delete iContactUsImage;
	iContactUsImage = NULL;
	delete iContactUsText;
	iContactUsText = NULL;
	delete iSystemSettingButton;
	iSystemSettingButton = NULL;
	delete iSystemSettingImage;
	iSystemSettingImage = NULL;
	delete iSystemSettingText;
	iSystemSettingText = NULL;
	delete iLineSeparator2;
	iLineSeparator2 = NULL;
	delete iBottomImage;
	iBottomImage = NULL;
	// ]]] end generated region [Generated Contents]
	
	}
				
/**
 * Construct the control (first phase).
 *  Creates an instance and initializes it.
 *  Instance is not left on cleanup stack.
 * @param aRect bounding rectangle
 * @param aParent owning parent, or NULL
 * @param aCommandObserver command observer
 * @return initialized instance of CSPDContainer
 */
CSPDContainer* CSPDContainer::NewL( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver )
	{
	CSPDContainer* self = CSPDContainer::NewLC( 
			aRect, 
			aParent, 
			aCommandObserver );
	CleanupStack::Pop( self );
	return self;
	}

/**
 * Construct the control (first phase).
 *  Creates an instance and initializes it.
 *  Instance is left on cleanup stack.
 * @param aRect The rectangle for this window
 * @param aParent owning parent, or NULL
 * @param aCommandObserver command observer
 * @return new instance of CSPDContainer
 */
CSPDContainer* CSPDContainer::NewLC( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver )
	{
	CSPDContainer* self = new ( ELeave ) CSPDContainer();
	CleanupStack::PushL( self );
	self->ConstructL( aRect, aParent, aCommandObserver );
	return self;
	}
			
/**
 * Construct the control (second phase).
 *  Creates a window to contain the controls and activates it.
 * @param aRect bounding rectangle
 * @param aCommandObserver command observer
 * @param aParent owning parent, or NULL
 */ 
void CSPDContainer::ConstructL( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver )
	{
	if ( aParent == NULL )
	    {
		CreateWindowL();
	    }
	else
	    {
	    SetContainerWindowL( *aParent );
	    }
	iFocusControl = NULL;
	iCommandObserver = aCommandObserver;
	InitializeControlsL();
	//SetRect( aRect );
	SetExtentToWholeScreen();
	ActivateL();
	// [[[ begin generated region: do not modify [Post-ActivateL initializations]
	// ]]] end generated region [Post-ActivateL initializations]
	
	}
			
/**
* Return the number of controls in the container (override)
* @return count
*/
TInt CSPDContainer::CountComponentControls() const
	{
	return ( int ) ELastControl;
	}
				
/**
* Get the control with the given index (override)
* @param aIndex Control index [0...n) (limited by #CountComponentControls)
* @return Pointer to control
*/
CCoeControl* CSPDContainer::ComponentControl( TInt aIndex ) const
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	switch ( aIndex )
		{
		case ELogo:
			return iLogo;
		case EWeatherButton:
			return iWeatherButton;
		case EWeather:
			return iWeather;
		case ECity:
			return iCity;
		case ETemperature:
			return iTemperature;
		case EDate:
			return iDate;
		case EWeatherDesc:
			return iWeatherDesc;
		case ENoticeButton:
			return iNoticeButton;
		case ENoticeIcon:
			return iNoticeIcon;
		case ENoticeText:
			return iNoticeText;
		case EHomeseparator1:
			return iHomeseparator1;
		case ELifeServiceButton:
			return iLifeServiceButton;
		case ELifeServiceImage:
			return iLifeServiceImage;
		case ELifeServiceText:
			return iLifeServiceText;
		case EDiscountInfoButton:
			return iDiscountInfoButton;
		case EDiscountInfoImage:
			return iDiscountInfoImage;
		case EDiscountInfoText:
			return iDiscountInfoText;
		case EProviderSearchButton:
			return iProviderSearchButton;
		case EProviderSearchImage:
			return iProviderSearchImage;
		case EProviderSearchText:
			return iProviderSearchText;
		case ESiteSearchButton:
			return iSiteSearchButton;
		case ESiteSearchImage:
			return iSiteSearchImage;
		case ESiteSearchText:
			return iSiteSearchText;
		case EProductInfoButton:
			return iProductInfoButton;
		case EProductInfoImage:
			return iProductInfoImage;
		case EProductInfoText:
			return iProductInfoText;
		case EFunGameButton:
			return iFunGameButton;
		case EFunGameImage:
			return iFunGameImage;
		case EFunGameText:
			return iFunGameText;
		case EContactUsButton:
			return iContactUsButton;
		case EContactUsImage:
			return iContactUsImage;
		case EContactUsText:
			return iContactUsText;
		case ESystemSettingButton:
			return iSystemSettingButton;
		case ESystemSettingImage:
			return iSystemSettingImage;
		case ESystemSettingText:
			return iSystemSettingText;
		case ELineSeparator2:
			return iLineSeparator2;
		case EBottomImage:
			return iBottomImage;
		}
	// ]]] end generated region [Generated Contents]
	
	// handle any user controls here...
	
	return NULL;
	}
				
/**
 *	Handle resizing of the container. This implementation will lay out
 *  full-sized controls like list boxes for any screen size, and will layout
 *  labels, editors, etc. to the size they were given in the UI designer.
 *  This code will need to be modified to adjust arbitrary controls to
 *  any screen size.
 */				
void CSPDContainer::SizeChanged()
	{
	CCoeControl::SizeChanged();
	LayoutControls();
	// [[[ begin generated region: do not modify [Generated Contents]
			
	// ]]] end generated region [Generated Contents]
	
	}
				
// [[[ begin generated function: do not modify
/**
 * Layout components as specified in the UI Designer
 */
void CSPDContainer::LayoutControls()
	{
	iLogo->SetExtent( TPoint( 0, 0 ), TSize( 360, 48 ) );
	iWeather->SetExtent( TPoint( 0, 70 ), TSize( 81, 81 ) );
	iCity->SetExtent( TPoint( 120, 72 ), TSize( 60, 34 ) );
	iTemperature->SetExtent( TPoint( 200, 72 ), TSize( 123, 34 ) );
	iDate->SetExtent( TPoint( 90, 112 ), TSize( 138, 28 ) );
	iWeatherDesc->SetExtent( TPoint( 240, 112 ), TSize( 110, 28 ) );
	iNoticeIcon->SetExtent( TPoint( 25, 166 ), TSize( 32, 32 ) );
	iNoticeText->SetExtent( TPoint( 67, 166 ), TSize( 283, 34 ) );
	iHomeseparator1->SetExtent( TPoint( 20, 220 ), TSize( 320, 2 ) );
	iLifeServiceImage->SetExtent( TPoint( 23, 290 ), TSize( 61, 61 ) );
	iLifeServiceText->SetExtent( TPoint( 20, 352 ), TSize( 68, 28 ) );
	iDiscountInfoImage->SetExtent( TPoint( 107, 290 ), TSize( 61, 61 ) );
	iDiscountInfoText->SetExtent( TPoint( 104, 352 ), TSize( 68, 28 ) );
	iProviderSearchImage->SetExtent( TPoint( 191, 290 ), TSize( 61, 61 ) );
	iProviderSearchText->SetExtent( TPoint( 188, 352 ), TSize( 68, 28 ) );
	iSiteSearchImage->SetExtent( TPoint( 275, 290 ), TSize( 61, 61 ) );
	iSiteSearchText->SetExtent( TPoint( 272, 352 ), TSize( 68, 28 ) );
	iProductInfoImage->SetExtent( TPoint( 23, 420 ), TSize( 61, 61 ) );
	iProductInfoText->SetExtent( TPoint( 20, 482 ), TSize( 68, 28 ) );
	iFunGameImage->SetExtent( TPoint( 107, 420 ), TSize( 61, 61 ) );
	iFunGameText->SetExtent( TPoint( 104, 482 ), TSize( 68, 28 ) );
	iContactUsImage->SetExtent( TPoint( 191, 420 ), TSize( 61, 61 ) );
	iContactUsText->SetExtent( TPoint( 188, 482 ), TSize( 68, 28 ) );
	iSystemSettingImage->SetExtent( TPoint( 275, 420 ), TSize( 61, 61 ) );
	iSystemSettingText->SetExtent( TPoint( 272, 482 ), TSize( 68, 28 ) );
	iLineSeparator2->SetExtent( TPoint( 20, 550 ), TSize( 320, 2 ) );
	iBottomImage->SetExtent( TPoint( 300, 600 ), TSize( 49, 19 ) );
	}
// ]]] end generated function

/**
 *	Handle key events.
 */				
TKeyResponse CSPDContainer::OfferKeyEventL( 
		const TKeyEvent& aKeyEvent, 
		TEventCode aType )
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	
	if ( HandleSPDContainerOfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
		{
		return EKeyWasConsumed;
		}
	
	// ]]] end generated region [Generated Contents]
	
	if ( iFocusControl != NULL
		&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
		{
		return EKeyWasConsumed;
		}
	return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
	}
				
// [[[ begin generated function: do not modify
/**
 *	Initialize each control upon creation.
 */				
void CSPDContainer::InitializeControlsL()
	{
	iLogo = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KTopbarFile, EMbmTopbarLogo, -1 );
		AknIconUtils::SetSize( bitmap, TSize( 360, 48 ), EAspectRatioPreserved );
		iLogo->SetPicture( bitmap );
		}
	iLogo->SetAlignment( EHCenterVTop );
	
	iWeatherButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iWeatherButton->ConstructFromResourceL ( R_SPDCONTAINER_WEATHER_BUTTON );
	
	iWeatherButton->SetContainerWindowL ( *this );
	iWeatherButton->SetRect ( TRect ( 
								TPoint ( 0, 70 ) , 
								TSize ( 360, 80 ) )  
								 ) ; 
	iWeatherButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iWeather = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KweatherFile, EMbmWeatherWheather01, EMbmWeatherWheather01_mask );
		AknIconUtils::SetSize( bitmap, TSize( 81, 81 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 81, 81 ), EAspectRatioPreserved );
		iWeather->SetPicture( bitmap, mask );
		}
	iWeather->SetAlignment( EHCenterVTop );
	iCity = new ( ELeave ) CEikLabel;
	iCity->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_CITY );
		iCity->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	iTemperature = new ( ELeave ) CEikLabel;
	iTemperature->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_TEMPERATURE );
		iTemperature->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	iDate = new ( ELeave ) CEikLabel;
	iDate->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_DATE );
		iDate->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	iWeatherDesc = new ( ELeave ) CEikLabel;
	iWeatherDesc->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_WEATHER_DESC );
		iWeatherDesc->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iNoticeButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iNoticeButton->ConstructFromResourceL ( R_SPDCONTAINER_NOTICE_BUTTON );
	
	iNoticeButton->SetContainerWindowL ( *this );
	iNoticeButton->SetRect ( TRect ( 
								TPoint ( 0, 160 ) , 
								TSize ( 360, 48 ) )  
								 ) ; 
	iNoticeButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iNoticeIcon = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KsmalliconsFile, EMbmSmalliconsIcon02, EMbmSmalliconsIcon02_mask );
		AknIconUtils::SetSize( bitmap, TSize( 32, 32 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 32, 32 ), EAspectRatioPreserved );
		iNoticeIcon->SetPicture( bitmap, mask );
		}
	iNoticeIcon->SetAlignment( EHCenterVTop );
	iNoticeText = new ( ELeave ) CEikLabel;
	iNoticeText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_NOTICE_TEXT );
		iNoticeText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	iHomeseparator1 = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KlineseparatorFile, EMbmLineseparatorLine01, EMbmLineseparatorLine01_mask );
		AknIconUtils::SetSize( bitmap, TSize( 320, 2 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 320, 2 ), EAspectRatioPreserved );
		iHomeseparator1->SetPicture( bitmap, mask );
		}
	iHomeseparator1->SetAlignment( EHCenterVTop );
	
	iLifeServiceButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iLifeServiceButton->ConstructFromResourceL ( R_SPDCONTAINER_LIFE_SERVICE_BUTTON );
	
	iLifeServiceButton->SetContainerWindowL ( *this );
	iLifeServiceButton->SetRect ( TRect ( 
								TPoint ( 20, 287 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iLifeServiceButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iLifeServiceButton->SetObserver( this );
	AddControlEventHandlerL( 
			iLifeServiceButton, 
			EEventStateChanged, 
			&CSPDContainer::HandleLifeServiceButtonStateChangedL );
	iLifeServiceImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf05, EMbmIconsPf05_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iLifeServiceImage->SetPicture( bitmap, mask );
		}
	iLifeServiceImage->SetAlignment( EHCenterVTop );
	iLifeServiceImage->SetObserver( this );
	AddControlEventHandlerL( 
			iLifeServiceImage, 
			EEventStateChanged, 
			&CSPDContainer::HandleLifeServiceImageStateChangedL );
	iLifeServiceText = new ( ELeave ) CEikLabel;
	iLifeServiceText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_LIFE_SERVICE_TEXT );
		iLifeServiceText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iDiscountInfoButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iDiscountInfoButton->ConstructFromResourceL ( R_SPDCONTAINER_DISCOUNT_INFO_BUTTON );
	
	iDiscountInfoButton->SetContainerWindowL ( *this );
	iDiscountInfoButton->SetRect ( TRect ( 
								TPoint ( 104, 287 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iDiscountInfoButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iDiscountInfoImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf15, EMbmIconsPf15_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iDiscountInfoImage->SetPicture( bitmap, mask );
		}
	iDiscountInfoImage->SetAlignment( EHCenterVTop );
	iDiscountInfoText = new ( ELeave ) CEikLabel;
	iDiscountInfoText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_DISCOUNT_INFO_TEXT );
		iDiscountInfoText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iProviderSearchButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iProviderSearchButton->ConstructFromResourceL ( R_SPDCONTAINER_PROVIDER_SEARCH_BUTTON );
	
	iProviderSearchButton->SetContainerWindowL ( *this );
	iProviderSearchButton->SetRect ( TRect ( 
								TPoint ( 188, 287 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iProviderSearchButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iProviderSearchImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf07, EMbmIconsPf07_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iProviderSearchImage->SetPicture( bitmap, mask );
		}
	iProviderSearchImage->SetAlignment( EHCenterVTop );
	iProviderSearchText = new ( ELeave ) CEikLabel;
	iProviderSearchText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_PROVIDER_SEARCH_TEXT );
		iProviderSearchText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iSiteSearchButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iSiteSearchButton->ConstructFromResourceL ( R_SPDCONTAINER_SITE_SEARCH_BUTTON );
	
	iSiteSearchButton->SetContainerWindowL ( *this );
	iSiteSearchButton->SetRect ( TRect ( 
								TPoint ( 272, 287 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iSiteSearchButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iSiteSearchImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf08, EMbmIconsPf08_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iSiteSearchImage->SetPicture( bitmap, mask );
		}
	iSiteSearchImage->SetAlignment( EHCenterVTop );
	iSiteSearchText = new ( ELeave ) CEikLabel;
	iSiteSearchText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_SITE_SEARCH_TEXT );
		iSiteSearchText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iProductInfoButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iProductInfoButton->ConstructFromResourceL ( R_SPDCONTAINER_PRODUCT_INFO_BUTTON );
	
	iProductInfoButton->SetContainerWindowL ( *this );
	iProductInfoButton->SetRect ( TRect ( 
								TPoint ( 20, 417 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iProductInfoButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iProductInfoImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf09, EMbmIconsPf09_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iProductInfoImage->SetPicture( bitmap, mask );
		}
	iProductInfoImage->SetAlignment( EHCenterVTop );
	iProductInfoText = new ( ELeave ) CEikLabel;
	iProductInfoText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_PRODUCT_INFO_TEXT );
		iProductInfoText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iFunGameButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iFunGameButton->ConstructFromResourceL ( R_SPDCONTAINER_FUN_GAME_BUTTON );
	
	iFunGameButton->SetContainerWindowL ( *this );
	iFunGameButton->SetRect ( TRect ( 
								TPoint ( 104, 417 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iFunGameButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iFunGameImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf10, EMbmIconsPf10_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iFunGameImage->SetPicture( bitmap, mask );
		}
	iFunGameImage->SetAlignment( EHCenterVTop );
	iFunGameText = new ( ELeave ) CEikLabel;
	iFunGameText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_FUN_GAME_TEXT );
		iFunGameText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iContactUsButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iContactUsButton->ConstructFromResourceL ( R_SPDCONTAINER_CONTACT_US_BUTTON );
	
	iContactUsButton->SetContainerWindowL ( *this );
	iContactUsButton->SetRect ( TRect ( 
								TPoint ( 188, 417 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iContactUsButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iContactUsImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf11, EMbmIconsPf11_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iContactUsImage->SetPicture( bitmap, mask );
		}
	iContactUsImage->SetAlignment( EHCenterVTop );
	iContactUsText = new ( ELeave ) CEikLabel;
	iContactUsText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_CONTACT_US_TEXT );
		iContactUsText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	
	iSystemSettingButton = static_cast< CAknButton* >
					( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
	iSystemSettingButton->ConstructFromResourceL ( R_SPDCONTAINER_SYSTEM_SETTING_BUTTON );
	
	iSystemSettingButton->SetContainerWindowL ( *this );
	iSystemSettingButton->SetRect ( TRect ( 
								TPoint ( 272, 417 ) , 
								TSize ( 67, 90 ) )  
								 ) ; 
	iSystemSettingButton->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
	
	
	
	
	
	
	iSystemSettingImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KiconsFile, EMbmIconsPf12, EMbmIconsPf12_mask );
		AknIconUtils::SetSize( bitmap, TSize( 61, 61 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 61, 61 ), EAspectRatioPreserved );
		iSystemSettingImage->SetPicture( bitmap, mask );
		}
	iSystemSettingImage->SetAlignment( EHCenterVTop );
	iSystemSettingText = new ( ELeave ) CEikLabel;
	iSystemSettingText->SetContainerWindowL( *this );
		{
		TResourceReader reader;
		iEikonEnv->CreateResourceReaderLC( reader, R_SPDCONTAINER_SYSTEM_SETTING_TEXT );
		iSystemSettingText->ConstructFromResourceL( reader );
		CleanupStack::PopAndDestroy(); // reader internal state
		}
	iLineSeparator2 = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KlineseparatorFile, EMbmLineseparatorLine01, EMbmLineseparatorLine01_mask );
		AknIconUtils::SetSize( bitmap, TSize( 320, 2 ), EAspectRatioPreserved );
		AknIconUtils::SetSize( mask, TSize( 320, 2 ), EAspectRatioPreserved );
		iLineSeparator2->SetPicture( bitmap, mask );
		}
	iLineSeparator2->SetAlignment( EHCenterVTop );
	iBottomImage = new ( ELeave ) CEikImage;
		{
		CFbsBitmap *bitmap, *mask;
		AknIconUtils::CreateIconL( bitmap, mask,
				KTopbarFile, EMbmTopbarBottom, -1 );
		AknIconUtils::SetSize( bitmap, TSize( 49, 19 ), EAspectRatioPreserved );
		iBottomImage->SetPicture( bitmap );
		}
	iBottomImage->SetAlignment( EHCenterVTop );
	
	iDiscountInfoButton->SetFocus( ETrue );
	iFocusControl = iDiscountInfoButton;
	
	}
// ]]] end generated function

/** 
 * Handle global resource changes, such as scalable UI or skin events (override)
 */
void CSPDContainer::HandleResourceChange( TInt aType )
	{
	CCoeControl::HandleResourceChange( aType );
	//SetRect( iAvkonViewAppUi->View( TUid::Uid( ESPDContainerViewId ) )->ClientRect() );
	SetRect( iAvkonViewAppUi->ApplicationRect() );
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	}
				
/**
 *	Draw container contents.
 */				
void CSPDContainer::Draw( const TRect& aRect ) const
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	CWindowGc& gc = SystemGc();
	gc.SetPenStyle( CGraphicsContext::ENullPen );
	TRgb backColor( 214,227,250 );
	gc.SetBrushColor( backColor );
	gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
	gc.DrawRect( aRect );
	
	// ]]] end generated region [Generated Contents]
	
	}
				
/** 
 * Handle focus change (override)
 */
void CSPDContainer::FocusChanged( TDrawNow aDrawNow )
	{
	CCoeControl::FocusChanged( aDrawNow );
	// [[[ begin generated region: do not modify [Generated Contents]
	HandleSPDContainerFocusChanged( aDrawNow );
	// ]]] end generated region [Generated Contents]
	
	}
				
/** 
 * Handle the focusChanged event.
 */
void CSPDContainer::HandleSPDContainerFocusChanged( TDrawNow aDrawNow )
	{
	// TODO: implement focusChanged event handler
	}
				
/** 
 * Override of the HandleControlEventL virtual function
 */
void CSPDContainer::HandleControlEventL( 
		CCoeControl* aControl, 
		TCoeEvent anEventType )
	{
	for (int i = 0; i < iControlEventDispatch.Count(); i++)
		{
		const TControlEventDispatch& currEntry = iControlEventDispatch[i];
		if ( currEntry.src == aControl && currEntry.event == anEventType )
			{
			( this->*currEntry.handler )( aControl, anEventType );
			break;
			}
		}
	}
/** 
 * Helper function to register MCoeControlObserver event handlers
 */
void CSPDContainer::AddControlEventHandlerL( 
		CCoeControl* aControl, 
		TCoeEvent anEvent, 
		ControlEventHandler aHandler )
	{
	TControlEventDispatch entry;
	entry.src = aControl;
	entry.event = anEvent;
	entry.handler = aHandler;
	TInt err = iControlEventDispatch.Append( entry );
	User::LeaveIfError( err );
	}
			
/** 
 * Handle the EEventStateChanged event.
 */
void CSPDContainer::HandleLifeServiceButtonStateChangedL( 
		CCoeControl* /* aControl */, 
		TCoeEvent /* anEvent */ )
	{
	// TODO: implement stateChanged event handler
	}
				
/** 
 * Handle the EEventStateChanged event.
 */
void CSPDContainer::HandleLifeServiceImageStateChangedL( 
		CCoeControl* aControl, 
		TCoeEvent anEvent )
	{
	// TODO: implement stateChanged event handler
	}
				
/** 
 * Handle the offerKeyEvent event.
 */
TKeyResponse CSPDContainer::HandleSPDContainerOfferKeyEventL( 
		const TKeyEvent& aKeyEvent, 
		TEventCode aType )
	{
	// TODO: implement offerKeyEvent event handler
	return EKeyWasNotConsumed;
	}
				
/** 
 * Handle pointer events (override)
 */
void CSPDContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
	{
	CCoeControl::HandlePointerEventL( aPointerEvent );
	
	// [[[ begin generated region: do not modify [Generated Contents]
	HandleSPDContainerPointerEventL( aPointerEvent );
	// ]]] end generated region [Generated Contents]
	
	}

/**
 *	Handle the pointerTouchEvent event
 */
void CSPDContainer::HandleSPDContainerPointerEventL( const TPointerEvent& aPointerEvent )
	{
	// TODO: implement pointerTouchEvent event handler
	if(aPointerEvent.iType != TPointerEvent::EButton1Up)
		{
		return;
		}
	
	if(iLifeServiceButton->Rect().Contains(aPointerEvent.iPosition)) 
		{
	    iAvkonViewAppUi->ActivateLocalViewL(TUid::Uid( ESPDLifeServiceContainerViewId ));
		}
	}

